#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bugatti cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false);
#define fi first
#define se second
#define max_heap(T) priority_queue<T>
#define min_heap(T) priority_queue<T, vector<T>, greater<T>>
#define fr(i, a, b) for(int i=a;i<b;i++)
#define frr(i, a, b) for(int i=a;i>b;i--)
#define frin(i, A) for(auto &i : A)
#define sz(x) (int)x.size()
#define all(A) A.begin(), A.end()
#define md(a, b) (a%b + b)%b
const ll INF = 2e9;
const ll MOD = 1e9 + 7;
const int MAXN = 1003;
const double eps = 1e-7;
int k, q, ans[MAXN];
double dp[MAXN];
void solve() {
cin >> k >> q;
dp[0] = 1;
int p = 1;
for(int i = 1; p < MAXN; i++) {
frr(j, k, 0)
dp[j] = j*1.0/k*dp[j] + (k-j+1)*1.0/k*dp[j-1];
while(p < MAXN && 2000*dp[k] >= (p))
ans[p++] = i;
dp[0] = 0;
}
while(q--) {
cin >> p;
cout << ans[p] << '\n';
}
}
int32_t main() {
bugatti
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
int T;
// cin >> T;
T = 1;
while(T--)
solve();
return 0;
}
50. Pow(x, n) | 43. Multiply Strings |
34. Find First and Last Position of Element in Sorted Array | 33. Search in Rotated Sorted Array |
17. Letter Combinations of a Phone Number | 5. Longest Palindromic Substring |
3. Longest Substring Without Repeating Characters | 1312. Minimum Insertion Steps to Make a String Palindrome |
1092. Shortest Common Supersequence | 1044. Longest Duplicate Substring |
1032. Stream of Characters | 987. Vertical Order Traversal of a Binary Tree |
952. Largest Component Size by Common Factor | 212. Word Search II |
174. Dungeon Game | 127. Word Ladder |
123. Best Time to Buy and Sell Stock III | 85. Maximal Rectangle |
84. Largest Rectangle in Histogram | 60. Permutation Sequence |
42. Trapping Rain Water | 32. Longest Valid Parentheses |
Cutting a material | Bubble Sort |
Number of triangles | AND path in a binary tree |
Factorial equations | Removal of vertices |
Happy segments | Cyclic shifts |